package com.nalanalana.spring6.validator.two;

import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @Project ：learn_spring
 * @File ：MyValidation1.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/4/7 16:19
 * @Description ：For study.
 */

@Service
public class MyValidation1 {

    @Autowired
    private Validator validator;

    public boolean validatorByUser1(User user) {
        Set<ConstraintViolation<User>> validate = validator.validate(user);
        return validate.isEmpty();
    }
}
